#define MSEMAIL_C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <libmscommon/mscommon.h>
#include <libmscommon/msmd.h>
#include <libmslog/mslog.h>
#include "msemail.h"

#define FLAG 		"EMAIL"
//Waring :Before modify this api, please concat su.gao
void msemail_api_send( MSEMAILContxt * pEmail_ctt)
{
#if defined(OS_LINUX_SOC)
	char tbuf[51200]={0};
	char cmdline[51200]={0};
	if(ms_false==msmd_api_isInstallByBin("sendemail")){
		return ;
	}
	///usr/bin/sendemail -s  smtp.163.com  -f dxebg@163.com  -t  kehu@163.com   -u  ebgyzm   -xu  dxebg   -xp dxebg   -o   tls=auto   -m   loginId:5241
	ms_strcats(tbuf,cmdline,"/usr/bin/sendemail -s %s ",pEmail_ctt->dns);
	ms_strcats(tbuf,cmdline,"-f       %s ",pEmail_ctt->from);
	ms_strcats(tbuf,cmdline,"-t       %s ",pEmail_ctt->to);
	ms_strcats(tbuf,cmdline,"-u      \"%s\" ",pEmail_ctt->theme);
	ms_strcats(tbuf,cmdline,"-xu    %s ",pEmail_ctt->user);
	ms_strcats(tbuf,cmdline,"-xp    %s ",pEmail_ctt->passwd);
	ms_strcats(tbuf,cmdline,"-o       %s ","tls=auto");
	ms_strcats(tbuf,cmdline,"-a       %s ",pEmail_ctt->attach);
	ms_strcats(tbuf,cmdline,"-m     \"%s\" ",pEmail_ctt->content);
	ms_verbose("%s",cmdline);
	ms_system(cmdline);
#else
	ms_funcNosupports;
#endif
}
#undef MSEMAIL_C